﻿
using UnityEngine;

//指示鼠标方向的标志
public class Pointer : MonoBehaviour
{
    private SpriteRenderer m_spriteRenderer;

    private float distance = 3f;
    public bool Active
    {
        set 
        {
            m_spriteRenderer.enabled = value;
        }
    }

    public Vector2 Direction
    {
        set
        {
            transform.position = Character.Instance.transform.position;
            transform.position -= new Vector3(value.x, value.y, 0f).normalized * distance;
            transform.eulerAngles = new Vector3(0f, 0f, -90f + value.ToAngle());
        }
    }

    private void Awake()
    {
        m_spriteRenderer = GetComponent<SpriteRenderer>();
    }

    private void FixedUpdate()
    {
        if (transform.lossyScale.x == -1)
            transform.localScale = new Vector3(1, 1, 1);
    }
}
